package ipc.project;

public class Friend {
	public String login;
	public String status;
	public String address;

	public Friend(String login, String status) {
		this.status = status;
		this.login = login;
	}

	public Friend(String login) {
		this.login=login;
		status = "";
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (!(obj instanceof Friend))
			return false;
		Friend f = (Friend) obj;
		return login.equals(f.login);

	}

	@Override
	public int hashCode() {
		return login.length();
	}
	
	public static String getLoginFromAddress(String address){
		int n = address.indexOf('@');
		return address.substring(0, n);
	}
}
